// run: $exec < input
// #pragma comment(linker,"/STACK:102400000,102400000")
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <set>
#include <vector>

int const maxn = 100007;
int n;

void manacher(std::vector<int> const & s, std::vector<int> & len, int n)
{
	for (int i = 0, j = 0, k; i < 2 * n; i += k, j = std::max(j - k, 0)) {
		while (i - j >= 0 && i + j + 1 < 2 * n && s[(i - j) / 2] == s[(i + j + 1) / 2]) j++;
		len[i] = j;
		for (k = 1; i - k >= 0 && j - k >= 0 && len[i - k] < j - k; k ++) {
			len[i + k] = std::min(len[i - k], j - k);
		}
	}
}

struct pd_r
{
	explicit pd_r() {}
	pd_r(int len, int pos) : len(len), pos(pos) {}

	int len, pos;
};

bool operator<(pd_r const & a, pd_r const & b)
{
	return a.len > b.len || (a.len == b.len && a.pos < b.pos);
}

int main()
{
	std::ios::sync_with_stdio(false);
	int T; std::cin >> T;
	for (int ti = 0; ti < T; ti++) {
		std::cout << "Case #" << ti << ": ";
		std::cin >> n;
		std::vector<int> da(n);
		std::vector<int> len(2*n+1);
		for (int i = 0; i < n; i++) std::cin >> da[i];
		manacher(da, len, n);
		std::vector<pd_r> a(n);
		for (int i = 1; i < 2 * n; i += 2)
			if (len[i] & 1)
				a[i / 2] = pd_r(0, i / 2);
			else
				a[i / 2] = pd_r(len[i] / 2, i / 2);

		std::cout << '\n';
		for (auto i : a) std::cout << i.pos << ' ' << i.len << '\n';
		std::cout << '\n';
		std::sort(a.begin(), a.end());

		std::set<int> pos;
		pos.insert(a[0].pos);
		for (int i = 1; i < n; i++) {
			int l = a[i].pos - a[i].len + 1;
			int r = a[i].pos + a[i].len;
			std::set<int>::iterator lit, rit;
			lit = std::lower_bound(lit);
		}


	}

}

